from typing import List, Optional, Dict, Any, Union
from sqlalchemy.orm import Session
from datetime import datetime

from app.db.models import Spider
from app.schemas.spider import SpiderCreate, SpiderUpdate


class CRUDSpider:
    def get(self, db: Session, id: str) -> Optional[Spider]:
        """根据ID获取爬虫"""
        return db.query(Spider).filter(Spider.id == id).first()
    
    # ... 其他方法保持不变 ...
    
    def remove(self, db: Session, id: str) -> Optional[Spider]:
        """删除爬虫"""
        db_obj = db.query(Spider).get(id)
        if db_obj:
            db.delete(db_obj)
            db.commit()
        return db_obj


crud_spider = CRUDSpider()